#include <Engine.h>
#include <Editor.h>
#include <Context.h>

int main( int argc, char *argv[] )
{
	Engine engine;
	Input in;
	Context scene;

	Editor editor;

	if( argc > 1 )
	{
		scene.Init( NULL );

		scene.LoadMap( argv[1] );

		editor.InitEditor( &engine );
		editor.InitObjects( &scene );

		while( engine.GetContinue( &in ) ) // Main loop
		{
			engine.Frame( &scene );
			in.LoadEvent();

			scene.LoadEvent( &in );

			engine.Interrupt();
		}

		engine.Quit();
	}
	else
	{
		string mapname;

		cout << "Enter name for your map : ";
		cin >> mapname;

		scene.Init( (char*)mapname.c_str() );

		editor.InitEditor( &engine );
		editor.InitObjects( &scene );

		while( engine.GetContinue( &in ) ) // Main loop
		{
			engine.Frame( &scene );
			in.LoadEvent();

			scene.LoadEvent( &in );

			engine.Interrupt();
		}

		engine.Quit();
	}

	return EXIT_SUCCESS;
}